package com.tfos.study.ssm.xml.controller;

import com.github.pagehelper.PageInfo;
import com.tfos.study.ssm.xml.entity.Organization;
import com.tfos.study.ssm.xml.service.OrganizationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类功能说明：机构管理控制类 <br/>
 * 公司名称：TF（腾飞）开源 <br/>
 * 作者：luorongxi <br/>
 */
@RestController
@RequestMapping("/org")
public class OrganizationController {

    @Resource
    private OrganizationService organizationService;

    /**
     * 分页列表查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/listforpage", method = RequestMethod.GET)
    public PageInfo<Organization> listForPage(@RequestParam(name = "pageNum",required = false,defaultValue = "1") Integer pageNum, @RequestParam(name="pageSize" ,required = false,defaultValue = "20") Integer pageSize) {
        return organizationService.listForPage(pageNum,pageSize);
    }

    /**
     * 根据id获取机构信息
     * @param orgId
     * @return
     */
    @RequestMapping(value = "/{orgId}", method = RequestMethod.GET)
    public Organization findById(@PathVariable(name = "orgId") Integer orgId) {
        return organizationService.findById(orgId);
    }

}
